package com.Questions.hash;

public class leetcode66 {
    public int[] plusOne(int[] digits) {
        return plus(digits,digits.length-1);
    }
    public int[] plus(int[] digits,int index){
        if(digits[index]==9){
            if(index!=0){
                digits[index]=0;
                return plus(digits,index-1);
            }else{
                int[] ans=new int[digits.length+1];
                ans[0]=1;
                for(int i=1;i<digits.length+1;++i){
                    ans[i]=0;
                }
                return ans;
            }
        }else{
            digits[index]=digits[index]+1;
            return digits;
        }
    }
}
